<meta content="text/html; charset=utf-8" http-equiv="content-type">
<?php
error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors','On'); 
require_once ('PHPExcel/Classes/PHPExcel.php');

$objPHPExcel = new PHPExcel();

$objReader = PHPExcel_IOFactory::createReader('Excel2007');

$objPHPExcel = $objReader->load('data.xlsx');

foreach ($objPHPExcel->getWorksheetIterator() as $worksheet){
    $worksheetTitle     = $worksheet->getTitle();
    $highestRow         = $worksheet->getHighestRow(); // e.g. 10
    $highestColumn      = $worksheet->getHighestColumn(); // e.g 'F'
    $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
    $nrColumns = ord($highestColumn) - 64;
    echo "<br>The worksheet ".$worksheetTitle." has ";
    echo $nrColumns . ' columns (A-' . $highestColumn . ') ';
    echo ' and ' . $highestRow . ' row.';
    echo '<br>Data: <table border="1"><tr>';
    
    
    
    //xây dựng ánh xạ index của excel đến table
    $arr_anhxa = array(
            '1' => 'name',
            '2' => 'Model_21',
            '3' => 'newprice',
            '4' => 'Cong_suat_22',
            '5' => 'Cong_suat_du_phong_34',
            '6' => 'Vo_28',
            '7' => ''
            );
    
    
    //chay theo dong
    for ($row = 1; $row <= $highestRow; ++ $row) {
        echo '<tr>';
        
        //chay theo cot
        for ($col = 0; $col < $highestColumnIndex; ++ $col) {
            $cell = $worksheet->getCellByColumnAndRow($col, $row);
            $val = $cell->getFormattedValue();
            //$dataType = PHPExcel_Cell_DataType::dataTypeForValue($val);
            
            //lấy giá trị dử liểu của từng ô
            echo '<td>' . $val . '</td>';
        }
        echo '</tr>';
    }
    echo '</table>';
    
    
    
    break;
}